
/* JavaScript content from js/Redmine.js in folder common */
/**
* @license
* Licensed Materials - Property of IBM
* 5725-G92 (C) Copyright IBM Corp. 2006, 2013. All Rights Reserved.
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/

function wlCommonInit(){

	/*
	 * Application is started in offline mode as defined by a connectOnStartup property in initOptions.js file.
	 * In order to begin communicating with Worklight Server you need to either:
	 * 
	 * 1. Change connectOnStartup property in initOptions.js to true. 
	 *    This will make Worklight framework automatically attempt to connect to Worklight Server as a part of application start-up.
	 *    Keep in mind - this may increase application start-up time.
	 *    
	 * 2. Use WL.Client.connect() API once connectivity to a Worklight Server is required. 
	 *    This API needs to be called only once, before any other WL.Client methods that communicate with the Worklight Server.
	 *    Don't forget to specify and implement onSuccess and onFailure callback functions for WL.Client.connect(), e.g:
	 *    
	  
	     */
	WL.Client.connect({
	     		onSuccess: onConnectSuccess,
	     		onFailure: onConnectFailure
	     });
	      
	 
	
	
	// Common initialization code goes here

}

//var pageHistory = [] ;

function  onConnectSuccess(){
	//listAllProjects();
	WL.Logger.debug("Redmine::wlCommonInit::connectSuccess");
//	pageHistory.push("pages/AllProjects.html");
	
	/*$("#content").load("views/AllProjects.html", function(){
		currentPage.init();
	});*/
	
	$.mobile.changePage("AllProjects.html",{changeHash : false,transition: "pop"});
}

function onConnectFailure(){
	WL.Logger.debug("Redmine::wlCommonInit::connectFailure");
	/*
	$("#content").load("pages/WorkOffline.html", function(){
		alert("Can't contact worklight Server");
	});
	*/
	$.mobile.changePage("WorkOffline.html",{changeHash : false,transition: "flip"});
}
/*
<input type="button" value="Logout" onclick="WL.Client.logout('CustomAuthenticatorRealm',{onSuccess: WL.Client.reloadApp})" />
*/
/* JavaScript content from js/Redmine.js in folder android */
/**
 *  @license
 *  Licensed Materials - Property of IBM
 *  5725-G92 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
 *  US Government Users Restricted Rights - Use, duplication or
 *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */

// This method is invoked after loading the main HTML and successful initialization of the Worklight runtime.
function wlEnvInit(){
    wlCommonInit();
    // Environment initialization code goes here
}